package boot.service.impl.travel;

import boot.dao.TravelMapper;
import boot.dao.WenchuangMapper;
import boot.domain.travel.Travel;
import boot.domain.travel.TravelExample;
import boot.domain.wenchuang.Wenchuang;
import boot.domain.wenchuang.WenchuangExample;
import boot.domain.wxGoods.Goods;
import boot.domain.wxGoods.GoodsExample;
import boot.service.travelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class travelServiceImpl implements travelService {
    @Autowired
    private TravelMapper travelMapper;
    @Override
    public boolean addTravel(Travel travel) {
        try {
            travelMapper.insert(travel);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public List<Travel> getAllTravel() {
        TravelExample travelExample = new TravelExample();
        TravelExample.Criteria criteria = travelExample.createCriteria();
        criteria.andIdIsNotNull();
        List<Travel> list = travelMapper.selectByExample(travelExample);
        System.out.println(list);
        return list;
    }

    @Override
    public Travel getTravelById(int travelId) {
        TravelExample travelExample = new TravelExample();
        TravelExample.Criteria criteria = travelExample.createCriteria();
        criteria.andIdEqualTo(travelId);
        List<Travel> list = travelMapper.selectByExample(travelExample);
        System.out.println(list);
//        System.out.println(goods);
        return list.get(0);
    }
}
